package com.game.centerserver.service.impl;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * 下载文件时需要使用到该类中的方法
 */
public class MultipartFileResource extends org.springframework.core.io.AbstractResource {
    private final MultipartFile file;

    public MultipartFileResource(MultipartFile file) {
        this.file = file;
    }

    @Override
    public String getFilename() {
        return file.getOriginalFilename();
    }

    @Override
    public String getDescription() {
        return null;
    }

    @Override
    public long contentLength() throws IOException {
        return file.getSize();
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return file.getInputStream();
    }
}
